package com.cc.blog.web.controller;

import com.cc.blog.common.annotation.ApiOperationLog;
import com.cc.blog.common.utils.Result;
import com.cc.blog.web.domain.dto.FindCategoryArticlePageListReqDTO;
import com.cc.blog.web.domain.dto.FindCategoryListReqDTO;
import com.cc.blog.web.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分类
 * @Author cc
 * @Date 2024/7/12 10:51
 */
@RestController
@RequestMapping("/category")
@Api(tags = "分类")
@AllArgsConstructor
public class CategoryController {

    private final CategoryService categoryService;

    @PostMapping("/list")
    @ApiOperation(value = "前台获取分类列表")
    @ApiOperationLog(description = "前台获取分类列表")
    public Result findCategoryList(@RequestBody @Validated FindCategoryListReqDTO findCategoryListReqDTO) {
        return categoryService.findCategoryList(findCategoryListReqDTO);
    }

    @PostMapping("/article/list")
    @ApiOperation(value = "前台获取分类下文章分页数据")
    @ApiOperationLog(description = "前台获取分类下文章分页数据")
    public Result findCategoryArticlePageList(@RequestBody @Validated FindCategoryArticlePageListReqDTO findCategoryArticlePageListReqDTO) {
        return categoryService.findCategoryArticlePageList(findCategoryArticlePageListReqDTO);
    }
}
